<template>
	<view>
		<view class="r-content" v-if="showInfo">
			<u-line color="#efefef" :customStyle="{ display: 'block' }"></u-line>
			<text class="state">{{ orderCarStatusStr }}</text>
			<view class="item" style="padding: 20rpx 30rpx 0; margin-top: 20rpx" id="baseInfo">
				<u-form :model="model.param" ref="uform" label-width="auto">
					<view style="height: 50rpx; display: flex; align-items: center">
						<u-icon
							name="order"
							color="#1573FF"
							:label="1 == returnCarType ? '换车信息' : '退车信息'"
							label-color="#333333"></u-icon>
					</view>

					<u-line color="#efefef" :customStyle="{ display: 'block' }"></u-line>

					<u-form-item
						label="换车退车时间"
						v-if="viewStateBean.timeApply[0]"
						:required="viewStateBean.timeApply[2]"
						borderBottom
						@click="viewStateBean.timeApply[1] && pickershow(1)">
						<u-input
							v-model="model.param.timeApply"
							inputAlign="right"
							:placeholder="viewStateBean.timeApply[1] ? '请选择' : '--'"
							disabled
							disabledColor="#ffffff"
							border="none"></u-input>

						<view slot="right">
							<u-icon v-if="viewStateBean.timeApply[1]" name="arrow-right"></u-icon>
						</view>
					</u-form-item>

					<u-form-item
						label="退车时间"
						v-if="viewStateBean.carBackTime[0]"
						:required="viewStateBean.carBackTime[2]"
						borderBottom
						@click="viewStateBean.carBackTime[1] && pickershow(2)">
						<u-input
							v-model="model.param.carBackTime"
							inputAlign="right"
							:placeholder="viewStateBean.carBackTime[1] ? '请选择' : '--'"
							disabled
							disabledColor="#ffffff"
							border="none"></u-input>

						<view slot="right">
							<u-icon v-if="viewStateBean.carBackTime[1]" name="arrow-right"></u-icon>
						</view>
					</u-form-item>

					<u-form-item
						label="退车类别"
						v-if="viewStateBean.carType[0]"
						:required="viewStateBean.carType[2]"
						borderBottom
						@click="viewStateBean.carType[1] && pickershow(3)">
						<u-input
							v-model="model.param.carTypeShow"
							inputAlign="right"
							:placeholder="viewStateBean.carType[1] ? '请选择' : '--'"
							disabled
							disabledColor="#ffffff"
							border="none"></u-input>

						<view slot="right">
							<u-icon v-if="viewStateBean.carType[1]" name="arrow-right"></u-icon>
						</view>
					</u-form-item>

					<u-form-item
						label="退车里程数"
						v-if="viewStateBean.alterationMileage[0]"
						:required="viewStateBean.alterationMileage[2]"
						borderBottom>
						<u-input
							v-model="model.param.alterationMileage"
							type="digit"
							inputAlign="right"
							:placeholder="viewStateBean.alterationMileage[1] ? '请输入' : '--'"
							:disabled="!viewStateBean.alterationMileage[1]"
							disabledColor="#ffffff"
							border="none"></u-input>
					</u-form-item>

					<u-form-item
						label="退车原因"
						v-if="viewStateBean.alterationDesc[0]"
						:required="viewStateBean.alterationDesc[2]"
						borderBottom>
						<u-input
							v-model="model.param.alterationDesc"
							inputAlign="right"
							:placeholder="viewStateBean.alterationDesc[1] ? '请输入' : '--'"
							:disabled="!viewStateBean.alterationDesc[1]"
							disabledColor="#ffffff"
							border="none"></u-input>
					</u-form-item>

					<u-form-item
						label="换车原因"
						v-if="viewStateBean.alterationType[0]"
						:required="viewStateBean.alterationType[2]"
						borderBottom>
						<u-input
							v-model="model.param.alterationType"
							inputAlign="right"
							:placeholder="viewStateBean.alterationType[1] ? '请输入' : '--'"
							:disabled="!viewStateBean.alterationType[1]"
							disabledColor="#ffffff"
							border="none"></u-input>
					</u-form-item>

					<u-form-item
						label="车辆退回仓库"
						v-if="viewStateBean.depot[0]"
						:required="viewStateBean.depot[2]"
						borderBottom
						@click="viewStateBean.depot[1] && pickershow(4)">
						<u-input
							v-model="model.param.depot"
							inputAlign="right"
							:placeholder="viewStateBean.depot[1] ? '请选择' : '--'"
							disabled
							disabledColor="#ffffff"
							border="none"></u-input>
						<view slot="right">
							<u-icon v-if="viewStateBean.depot[1]" name="arrow-right"></u-icon>
						</view>
					</u-form-item>

					<u-form-item
						label="更改车辆状态"
						v-if="viewStateBean.shipType[0]"
						:required="viewStateBean.shipType[2]"
						borderBottom
						@click="viewStateBean.shipType[1] && shipTypeClick()">
						<u-input
							v-model="model.param.shipTypeName"
							inputAlign="right"
							disabled
							disabledColor="#ffffff"
							border="none"
							placeholder="请选择车辆状态"></u-input>

						<view slot="right">
							<u-icon v-if="viewStateBean.shipType[1]" name="arrow-right"></u-icon>
						</view>
					</u-form-item>

					<u-form-item
						label="退款时间"
						v-if="viewStateBean.refundTime[0]"
						:required="viewStateBean.refundTime[2]"
						borderBottom
						@click="viewStateBean.refundTime[1] && pickershow(5)">
						<u-input
							v-model="model.param.refundTime"
							inputAlign="right"
							:placeholder="viewStateBean.refundTime[1] ? '请选择' : '--'"
							disabled
							disabledColor="#ffffff"
							border="none"></u-input>
						<view slot="right">
							<u-icon v-if="viewStateBean.refundTime[1]" name="arrow-right"></u-icon>
						</view>
					</u-form-item>
					<view v-if="pageType !== 'detail'">
						<view v-for="(val, key, i) in feeItemConfig" :key="key" v-if="!val.hide">
							<view
								style="
									height: 50rpx;
									display: flex;
									align-items: center;
									padding: 10px 0px;
									border-bottom: 1px solid #e3e6ec;
								">
								<u-icon
									name="order"
									color="#1573FF"
									:label="val.fieldName"
									label-color="#333333"></u-icon>
							</view>
							<u-form-item
								v-for="(item, k, index) in val.feeItemConfig"
								:label="item.serviceName"
								:required="val.edit && item.valRequired"
								borderBottom>
								<template #labelRight v-if="item.serviceName == '车辆租金欠款金额'">
									<view @click="tip" style="padding-left: 5rpx">
										<u-icon size="18" name="info-circle-fill"></u-icon>
									</view>
								</template>
								<u-input
									v-if="item.serviceProperty == 1 || item.serviceProperty == 2"
									:ref="k"
									v-model="feeItemConfig[key]['feeItemConfig'][k].value"
									inputAlign="right"
									type="digit"
									:disabled="!val.edit"
									maxlength="10"
									disabledColor="#ffffff"
									border="none"
									placeholder="请输入"
									@input="inputBlur"></u-input>
								<u-input
									v-else
									v-model="feeItemConfig[key]['feeItemConfig'][k].value"
									inputAlign="right"
									type="text"
									:disabled="!val.edit"
									maxlength="200"
									disabledColor="#ffffff"
									border="none"
									placeholder="请输入"
									@input="inputBlur"></u-input>
							</u-form-item>
						</view>
					</view>
					<view v-else>
						<view v-for="(val, key, i) in feeItemConfig" :key="key" v-if="!val.hide">
							<view
								style="
									height: 50rpx;
									display: flex;
									align-items: center;
									padding: 10px 0;
									border-bottom: 1px solid #e3e6ec;
								">
								<u-icon
									name="order"
									color="#1573FF"
									:label="val.fieldName"
									label-color="#333333"></u-icon>
							</view>
							<u-form-item
								v-for="(item, k, index) in val.feeItemConfig"
								:key="k"
								:label="item.serviceName"
								:required="val.edit && item.valRequired"
								borderBottom>
								<template #labelRight v-if="item.serviceName == '车辆租金欠款金额'">
									<view @click="tip" style="padding-left: 5rpx">
										<u-icon size="18" name="info-circle-fill"></u-icon>
									</view>
								</template>
								<u-input
									v-if="item.serviceProperty == 1 || item.serviceProperty == 2"
									:ref="k"
									v-model="feeItemConfig[key]['feeItemConfig'][k].value"
									inputAlign="right"
									type="digit"
									:disabled="!val.edit"
									maxlength="10"
									disabledColor="#ffffff"
									border="none"
									placeholder="请输入"
									@input="inputBlur"></u-input>
								<u-input
									v-else
									v-model="feeItemConfig[key]['feeItemConfig'][k].value"
									inputAlign="right"
									type="text"
									:disabled="!val.edit"
									maxlength="200"
									disabledColor="#ffffff"
									border="none"
									placeholder="请输入"
									@input="inputBlur"></u-input>
							</u-form-item>
						</view>
					</view>

					<view
						v-if="viewStateBean.uploadAttach[0]"
						style="display: flex; flex-direction: column">
						<u-form-item
							:required="viewStateBean.uploadAttach[2]"
							label="凭证"></u-form-item>

						<lr-upload
							:disabled="!viewStateBean.uploadAttach[1]"
							ref="upload1"
							:objType="1 == returnCarType ? '13' : '14'"
							tag="1"
							@on-change="uploadOnChange"></lr-upload>

						<view
							style="
								margin: 20rpx;
								display: flex;
								align-items: center;
								justify-content: space-between;
							"
							v-for="(pitem, pindex) in pdflist"
							:key="pindex"
							class="pdf-item">
							<text style="font-size: 26rpx; color: #333">
								{{ pitem.nameFile || pitem.name_file }}
							</text>
							<text style="color: #1573ff; font-size: 26rpx" @click="viewpdf(pitem)">
								查看
							</text>
						</view>
					</view>

					<view v-if="viewStateBean.settleAmount[0]" class="bottom-text">
						<text style="color: #e93131; font-size: 28rpx">
							{{ newAmount < 0 ? '退还金额:' : '补缴金额:' }}
						</text>
						<text style="color: #333333; font-size: 32rpx">
							￥{{ Math.abs(newAmount) }}
						</text>
					</view>
				</u-form>
			</view>

			<examFlow :listData="model.bpmChartDtoList" :isForceShow="true"></examFlow>

			<view style="height: 100rpx"></view>

			<view class="button-container" v-if="model.buttonList && model.buttonList.length > 0">
				<button
					class="btn-item"
					v-for="(bitem, bindex) in model.buttonList"
					:key="bindex"
					@click="bottomClick(bitem)">
					{{ bitem.btnName }}
				</button>
			</view>
		</view>

		<no-data v-else></no-data>

		<!-- 换车时间 -->
		<u-datetime-picker
			:show="changeShow"
			:maxDate="maxDate"
			:minDate="minDate"
			mode="date"
			@confirm="timeConfirm"
			@cancel="changeShow = false"></u-datetime-picker>

		<!-- 退车时间 -->
		<u-datetime-picker
			:show="returnShow"
			mode="date"
			@confirm="timeConfirm"
			@cancel="returnShow = false"></u-datetime-picker>

		<!-- 退款时间 -->
		<u-datetime-picker
			:show="refundShow"
			mode="date"
			@confirm="timeConfirm"
			@cancel="refundShow = false"></u-datetime-picker>

		<!-- 退车类别 -->
		<u-picker
			:mode="mode"
			:show="rentTypeShow"
			:default-selector="[0]"
			:columns="rentTypeList"
			keyName="value"
			@confirm="pickerConfim"
			@cancel="rentTypeShow = false"></u-picker>

		<!-- 车辆仓库 -->
		<u-picker
			:mode="mode"
			:show="warehouseSshow"
			:default-selector="[0]"
			:columns="carWarehouseList"
			keyName="warehouseName"
			@confirm="pickerConfim"
			@cancel="warehouseSshow = false"></u-picker>

		<!-- 车辆状态 -->
		<u-picker
			:mode="mode"
			:show="shipTypeShow"
			:default-selector="[0]"
			:columns="shipList"
			keyName="shipName"
			@confirm="shipTypeConfirm"
			@cancel="shipTypeShow = false"></u-picker>
		<u-modal :show="show" :closeOnClickOverlay="true" @confirm="closeTip" @close="closeTip">
			<view class="slot-content">
				<view>根据公司所设定的退租规则来计算退车租金，退车租金结算方式：</view>
				<div>1、按实际使用天数计算</div>
				<div>2、按原周期账单方式结算</div>
			</view>
		</u-modal>
	</view>
</template>

<script>
	import examFlow from '@/components/exam-flow.vue';
	import lrUpload from '@/components/global/lr-upload.vue';
	import { isVideo } from '@/common/calc';
	var moment = require('@/common/moment.js');
	export default {
		components: {
			lrUpload,
			examFlow,
		},
		data() {
			return {
				maxDate: moment().add(10, 'years').valueOf(),
				minDate: moment().add(-10, 'years').valueOf(),
				processStr: '',
				changeShow: false,
				returnShow: false,
				refundShow: false,
				rentTypeShow: false,
				warehouseSshow: false,
				shipTypeShow: false,
				orderCarNo: '',
				returnCarType: '',
				rentType: '',
				orderCarId: '',
				instanceId: '',
				pageType: 'datail',
				rentTypeList: [],
				carWarehouseList: [],
				shipList: [],
				orderCarStatusStr: '',
				model: {
					// bpmChartDtoList: [],
					// moduleDtoList: {},
					// param: {
					// 	uploadAttach:[]
					// },
					// buttonList: [],
					// rejectedPerson: ''
				},
				feeItemConfig: {},
				viewStateBean: {
					actualAmount: [false, false, false],
					addInsuranceFee: [false, false, false],
					alterationDesc: [false, false, false],
					alterationMileage: [false, false, false],
					bankAccount: [false, false, false],
					bankName: [false, false, false],
					carBackTime: [false, false, false],
					refundTime: [false, false, false],
					carType: [false, false, false],
					collectFee: [false, false, false],
					dangerAmount: [false, false, false],
					dangerCount: [false, false, false],
					deductionAmount: [false, false, false],
					defaultAmount: [false, false, false],
					depot: [false, false, false],
					feeDesc: [false, false, false],
					illegalAmount: [false, false, false],
					illegalScore: [false, false, false],
					maintenanceReduce: [false, false, false],
					margin: [false, false, false],
					otherAmount: [false, false, false],
					otherFee: [false, false, false],
					payType: [false, false, false],
					refundAccountName: [false, false, false],
					rentAmount: [false, false, false],
					rentCarMileage: [false, false, false],
					settleAmount: [false, false, false],
					shipType: [false, false, false],
					transferCommission: [false, false, false],
					uploadAttach: [false, false, false],
					washCarReduce: [false, false, false],
					timeApply: [false, false, false],
					alterationType: [false, false, false],
				},
				pickerType: '',
				newAmount: 0,
				show: false,
			};
		},
		computed: {
			showInfo() {
				return !uni.$u.test.isEmpty(this.model);
			},
			pdflist() {
				return this.model && this.model.param && this.model.param.uploadAttach
					? this.model.param.uploadAttach.filter(item => {
							if ('0' == item.typeFile || '0' == item.type_file) {
								return item;
							}
					  })
					: [];
			},
		},
		mounted() {
			let that = this;
			that.$nextTick(function () {
				setTimeout(() => {
					for (var key in that.feeItemConfig) {
						for (var k in that.feeItemConfig[key].feeItemConfig) {
							if (
								that.feeItemConfig[key].feeItemConfig[k].serviceProperty === 1 ||
								that.feeItemConfig[key].feeItemConfig[k].serviceProperty === 2
							) {
								console.log(that.$refs, 'that.$refs');
								that.$refs[k][0].setFormatter(e => {
									return e
										.replace(/[^\d.]/g, '')
										.replace(/\.{2,}/g, '.')
										.replace(/^(-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
								});
							}
						}
					}
				}, 1500);
			});
		},
		methods: {
			closeTip() {
				this.show = false;
			},
			tip() {
				this.show = true;
			},
			viewpdf(item) {
				uni.showLoading();
				let that = this;

				let fileType = 'pdf';
				if (!uni.$u.test.isEmpty(item.url)) {
					fileType = item.url.split('.')[1];
				}

				uni.downloadFile({
					url: that.baseImgUrl() + item.url,
					filePath: '',
					success(res) {
						uni.hideLoading();

						console.log('下载成功了', res);

						let tempPath = res.tempFilePath;
						uni.openDocument({
							showMenu: true,
							filePath: tempPath,
							fileType: fileType,
						});
					},
					fail(e) {
						uni.hideLoading();
					},
				});
			},
			// 动态字段失去焦点变化
			inputBlur() {
				let that = this;
				let num = 0;
				for (var key in that.feeItemConfig) {
					for (var k in that.feeItemConfig[key].feeItemConfig) {
						if (that.feeItemConfig[key].feeItemConfig[k].serviceProperty === 1) {
							// num -= Number(that.feeItemConfig[key].feeItemConfig[k].value || 0)
							num = Number(num).sub(
								Number(that.feeItemConfig[key].feeItemConfig[k].value || 0),
							);
						} else if (that.feeItemConfig[key].feeItemConfig[k].serviceProperty === 2) {
							// num += Number(that.feeItemConfig[key].feeItemConfig[k].value || 0)
							num = Number(num).add(
								Number(that.feeItemConfig[key].feeItemConfig[k].value || 0),
							);
						} else {
						}
					}
				}
				that.newAmount = num;
			},
			setViewState() {
				let that = this;
				//处理动态数据
				if (
					!uni.$u.test.isEmpty(that.model) &&
					!uni.$u.test.isEmpty(that.model.moduleDtoList) &&
					!uni.$u.test.isEmpty(that.model.moduleDtoList.fields)
				) {
					for (let field of that.model.moduleDtoList.fields) {
						that.viewStateBean[field.fieldInfo] = [
							!field.hide,
							field.edit,
							field.required,
						];
					}
				}
				this.$forceUpdate();
			},
			shipTypeClick() {
				this.shipTypeShow = true;
			},
			//picker是否显示
			pickershow(type) {
				switch (type) {
					case 1:
						this.changeShow = true;
						break;
					case 2:
						this.returnShow = true;
						break;
					case 3:
						this.rentTypeShow = true;
						break;
					case 4:
						this.warehouseSshow = true;
						break;
					case 5:
						this.refundShow = true;
						break;
				}
				this.pickerType = type;
			},

			timeConfirm(e) {
				let timeStr = uni.$u.timeFormat(e.value, 'yyyy-mm-dd');

				switch (this.pickerType) {
					case 1: //换车时间
						this.changeShow = false;
						this.model.param.timeApply = timeStr;

						this.$u.api
							.transferMonthlyRentDebt(
								this.orderCarNo,
								moment(this.model.param.timeApply).valueOf(),
							)
							.then(res => {
								console.log(this.feeItemConfig);

								// this.model.feeItemConfig.serviceConfig4.feeItemConfig.rentAmount.value = Number(res.monthlyRentDebt).toFixed(2)
								this.findAndSetOtherAmount(
									this.feeItemConfig,
									'rentAmount',
									this.formatNumber(res.monthlyRentDebt),
								);
								// this.model.rentAmount = Number(res.monthlyRentDebt).toFixed(2)
								console.log('this.model.rentAmount', this.model.rentAmount);
								// this.inputBlur()
								// this.$forceUpdate()
							});

						break;
					case 2: //退车时间
						this.returnShow = false;
						this.model.param.carBackTime = timeStr;
						break;
					case 5: //退款时间
						this.refundShow = false;
						this.model.param.refundTime = timeStr;
						break;
				}
			},
			formatNumber(money) {
				return new Number(money || 0).toFixed(3).replace(/([0-9]+\.[0-9]{2})[0-9]*/, '$1');
			},
			findAndSetOtherAmount(obj, name, newValue) {
				let that = this;
				for (const key in obj) {
					if (obj.hasOwnProperty(key)) {
						if (key === name) {
							// 找到 otherAmount 并赋值
							if (typeof obj[key] === 'object') {
								obj[key].value = newValue;
								that.inputBlur();
								that.$forceUpdate();
							} else {
								obj[key] = newValue;
								that.inputBlur();
								that.$forceUpdate();
							}

							console.log('key', obj);
						} else if (typeof obj[key] === 'object' && obj[key] !== null) {
							// 递归遍历子对象
							this.findAndSetOtherAmount(obj[key], name, newValue);
						}
					}
				}
			},
			//picker回调函数
			pickerConfim(e) {
				switch (this.pickerType) {
					case 3: //退车类别
						this.rentTypeShow = false;
						// let carInfoObjc = this.carInfoList[index];
						let rentTypeObjc = e.value[0];

						this.model.param.carType = rentTypeObjc.code;
						this.model.param.carTypeShow = rentTypeObjc.value;

						break;
					case 4: //退车类别
						this.warehouseSshow = false;
						// let carInfoObjc = this.carInfoList[index];
						let warehouseObjc = e.value[0];

						this.model.param.depotId = warehouseObjc.warehouseId;
						this.model.param.depot = warehouseObjc.warehouseName;

						break;
				}
			},

			bottomClick(item) {
				switch (item.btnKey) {
					case '401':
						this.$u.api
							.applyforAppEdit({
								...this.model.param,
								feeItemConfig: this.feeItemConfig,
							})
							.then(res => {
								this.$u.toast('编辑成功');
								setTimeout(() => {
									uni.navigateBack();
								}, 1000);
							});
						break;
					case '402':
						getApp().globalData.refundOrChangeCarModel = {
							...this.model.param,
							feeItemConfig: this.feeItemConfig,
						};

						console.log('提交数据', getApp().globalData.refundOrChangeCarModel);

						let that = this;

						for (const item in that.feeItemConfig) {
							let itemVal = that.feeItemConfig[item];
							for (const sitem in itemVal.feeItemConfig) {
								let sitemVal = itemVal.feeItemConfig[sitem];
								if (
									itemVal.edit &&
									sitemVal.valRequired &&
									(sitemVal.value == undefined ||
										sitemVal.value == null ||
										sitemVal.value == '')
								) {
									// that.$u.toast('请输入', sitemVal.serviceName)
									uni.showToast({
										title: `请输入${sitemVal.serviceName}`,
										icon: 'error',
									});
									console.log('请输入', sitemVal.serviceName);
									return false;
								}
							}
						}

						uni.navigateTo({
							url:
								'/pagesB/exam-order/exam-refundandchange?title=确认通过&btnKey=' +
								item.btnKey,
						});
						break;
					case '403':
						getApp().globalData.refundOrChangeCarModel = {
							...this.model.param,
							feeItemConfig: this.feeItemConfig,
						};

						uni.navigateTo({
							url:
								`/pagesB/exam-order/exam-refundandchange?title=确认驳回${this.model.rejectedPerson}节点&btnKey=` +
								item.btnKey,
						});
						break;
					case '404':
						// getApp().globalData.refundOrChangeCarModel = this.model.param
						getApp().globalData.refundOrChangeCarModel = {
							...this.model.param,
							feeItemConfig: this.feeItemConfig,
						};

						uni.navigateTo({
							url:
								'/pagesB/exam-order/exam-refundandchange?title=确认拒绝&btnKey=' +
								item.btnKey,
						});
						break;
					case '405':
						getApp().globalData.refundOrChangeCarModel = {
							...this.model.param,
							feeItemConfig: this.feeItemConfig,
						};

						uni.redirectTo({
							url:
								'/pagesB/exam-order/exam-refundandchange?title=确认撤单&btnKey=' +
								item.btnKey,
						});
						break;
				}
			},

			shipTypeConfirm(e) {
				this.shipTypeShow = false;
				this.model.param.shipType = e.value[0].shipValue;
				this.model.param.shipTypeName = e.value[0].shipName;
			},

			//图片上传成功回调
			uploadOnChange(tag, resultList, resultObjList) {
				console.log(tag, resultList, resultObjList);
				switch (tag) {
					case '1': //附件
						this.model.param.uploadAttach = resultObjList;
						break;
				}
			},

			getData() {
				let that = this;
				this.$u.api
					.applyforDetail({
						orderCarNo: that.orderCarNo,
						processKey: that.processStr,
						instanceId: that.instanceId,
						alterationType: that.returnCarType,
					})
					.then(res => {
						that.model = res;

						// if(that.pageType!=='detail'){
						if (
							that.model &&
							that.model.buttonList &&
							!uni.$u.test.isEmpty(that.model.buttonList)
						) {
							that.pageType = 'edit';
						} else {
							that.pageType = 'detail';
						}
						// }

						that.getFlowData();

						if (!uni.$u.test.isEmpty(that.model)) {
							console.log('model==>', that.model);
							that.orderCarStatusStr = that.model.param.orderCarStatusStr;

							that.model.param.returnCarType = that.returnCarType;
							that.model.param.processKey = that.processStr;
							//处理动态数据
							that.setViewState();
							setTimeout(() => {
								if (
									!uni.$u.test.isEmpty(that.model.param.uploadAttach) &&
									!uni.$u.test.isEmpty(that.$refs.upload1)
								) {
									that.$refs.upload1.fileList1 = that.model.param.uploadAttach
										.filter(item => {
											return 1 == item.type_file || 1 == item.typeFile;
										})
										.map(item => {
											return {
												...item,
												message: '',
												size: 52363,
												status: 'success',
												thumb: that.baseImgUrl() + item.url,
												type: isVideo(item.url),
												url: item.url,
											};
										});

									console.log('===>', that.$refs.upload1.fileList1);
								}
							}, 1500);
						} else {
							console.log('this.model=============是空');
						}
					})
					.catch(e => {
						that.getFlowData();
					});
			},

			getFlowData() {
				if (this.pageType === 'detail') {
					this.$u.api
						.applyfeeDetail({
							orderCarId: this.orderCarId,
							instanceId: this.instanceId,
							suitType: this.returnCarType === '1' ? '2' : '1',
						})
						.then(res => {
							this.feeItemConfig = res;
							this.inputBlur();
						});
				} else {
					this.$u.api
						.getServiceConfig({
							rentType: this.rentType,
							orderCarId: this.orderCarId,
							suitType: this.returnCarType === '1' ? '2' : '1',
							instanceId: this.instanceId,
						})
						.then(res => {
							this.feeItemConfig = res;
							this.inputBlur();
						});
				}
			},
		},

		// onShow() {
		//
		//
		//
		//   this.getData()
		// },

		onLoad(op) {
			console.log('op==', op);
			this.orderCarNo = 'null' != op.orderCarNo ? op.orderCarNo : '';
			this.returnCarType = 'null' != op.returnCarType ? op.returnCarType : '';
			this.rentType = 'null' != op.rentType ? op.rentType : '';
			this.orderCarId = 'null' != op.orderCarId ? op.orderCarId : '';
			this.instanceId = 'null' != op.instanceId && op.instanceId ? op.instanceId : '';
			this.pageType = op.pageType ? op.pageType : 'detail';
			// this.orderCarStatusStr = 'null' != op.orderCarStatusStr ? op.orderCarStatusStr : ''
			this.querychoice = this.$store.state.params.getCarCommon;
			this.rentTypeList = [this.querychoice.rentType];
			this.carWarehouseList = [this.$store.state.params.warehouseList];
			let that = this;
			if (1 == this.returnCarType) {
				uni.setNavigationBarTitle({
					title: '换车信息',
				});
				this.processStr = 2 == this.rentType ? 'rentSaleTransferCar' : 'rentTransferCar';
				this.$u.api
					.transferInfoByOrderCarId({
						orderCarId: this.orderCarId,
					})
					.then(res => {
						let { currTimeStartRent, timeStartRent, timeFinishRent } = res;

						this.maxDate = moment(timeFinishRent).valueOf();
						this.minDate = currTimeStartRent
							? moment(currTimeStartRent).valueOf()
							: moment(timeStartRent).valueOf();
					});
			} else if (2 == this.returnCarType) {
				uni.setNavigationBarTitle({
					title: '退车信息',
				});
				this.processStr =
					2 == this.rentType
						? 'rentSaleApprove'
						: 6 == this.rentType
						? 'purchaseBackApprove'
						: 'carBackApprove';
			}
			// if (that.pageType === 'detail') {
			//   this.$u.api.applyfeeDetail({
			//     orderCarId: this.orderCarId,
			//     suitType: this.returnCarType === '1' ? '2' : '1'
			//   }).then(res => {
			//     this.feeItemConfig = res
			//     this.inputBlur()
			//   })
			// } else {
			//   this.$u.api.getServiceConfig({
			//     rentType: this.rentType,
			//     orderCarId: this.orderCarId,
			//     suitType: this.returnCarType === '1' ? '2' : '1',
			//     instanceId: this.instanceId
			//   }).then(res => {
			//     this.feeItemConfig = res
			//     this.inputBlur()
			//   })
			// }
			uni.$on('refund-finish', res => {
				this.getData();
			});
			// uni.$on('callback-finish', res=>{
			// 	uni.navigateBack()
			// })
			this.shipList = [
				[
					{
						shipName: '整备中',
						shipValue: '1',
					},
					{
						shipName: '备发车',
						shipValue: '2',
					},
				],
			];

			this.getData();
		},
	};
</script>

<style lang="scss" scoped>
	.r-content {
		display: flex;
		flex-direction: column;
	}

	.state {
		width: 100%;
		line-height: 118rpx;
		text-align: center;
		font-size: 45rpx;
		color: #ffc000;
		font-weight: bold;
		background-color: #fff;
	}

	.bottom-text {
		display: flex;
		align-items: flex-end;
		height: 50rpx;
		margin-right: 20rpx;
		margin-bottom: 20rpx;
		justify-content: flex-end;
	}

	// .btn-item{
	// 	flex: 1;
	// 	line-height: 80rpx;
	// 	border-radius: 40rpx;
	// 	margin: 0 10rpx;
	// 	background-color: $xz-bgColor-blue;
	// 	color: white;
	// 	white-space: nowrap;
	// 	font-size: 30rpx;
	// }

	// .button-container {
	// 	display: flex;
	// 	position: fixed;
	// 	left: 0;
	// 	right: 0;
	// 	height: 100rpx;
	// 	bottom: 0;
	// 	z-index: 999;
	// 	background-color: white;
	// 	align-items: center;
	// 	margin: 0 10rpx;
	// }
</style>
